<?php
include '../../server/core/ArrowObject.php';
include '../../server/core/ArrowLogger.php';

class DbTest {

  private $log_path =  './' ;
  private $log = null ;  

  public function __construct() {
    session_start();
    if( !isset($_SESSION['start']) ) {
      $_SESSION['start'] = 0 ;
	  $_SESSION['token'] = md5( time() ) ;
	}
	$this->log = new ArrowLogger( $this->log_path.'log_'.$_SESSION['token'].'.html'  );
  }

  public function run() {
    $dir = new DirectoryIterator('./tests');
    $i = 0 ;
    foreach ($dir as $fileinfo) {
       if ($fileinfo->isFile() && $i >= $_SESSION['start'] ) {
          include $fileinfo->getPathName() ;
          $t = new Test();
          ArrowLogger::log(  "<h2>".$t->getQuery()."</h2>", 1, $this->log );
		  
		  $this->runTest( $t->getQuery(), $t->getCriteria() ) ;      
          
          ++$_SESSION['start'];
          exit();
       }
	   ++$i;
    }
  }
  
  
  private function runTest( $query, $criteria ) {
    
    ArrowLogger::log( "pass false", 1, $this->log );
	
	// wykonanie zapytania mysql
	
	//wykonanie zapytania ormem
	
	//porównanie obiektów po serializacji
	
  }
  
  public function clean() {
  	unset( $_SESSION['start'] ) ;
	unset( $_SESSION['token'] ) ;
	
  }
  

}


 $tests = new DBTest();
 
 $tests->run();

 echo "all test finish";
 $tests->clean();
?>